package co.edu.poli.ficb.agl.automatable.examples;

import javax.swing.JFrame;

import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.graph.DirectedGraph;
import edu.uci.ics.jung.graph.DirectedSparseMultigraph;
import edu.uci.ics.jung.visualization.GraphZoomScrollPane;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
import edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position;

public class PruebaJung {
	public static void main(String[] args) {
		DirectedGraph<Integer, String> graph = new DirectedSparseMultigraph<Integer, String>();
		int n=5;
		for (int i=1; i<n; i++) graph.addVertex(i);
		for (int i=1; i<n; i++) for (int j=i+1; j<n; j++) graph.addEdge(i+","+j, i, j);
		VisualizationViewer<Integer, String> viewer = new VisualizationViewer<Integer, String>(new CircleLayout<Integer, String>(graph));
		/*
		viewer.getRenderContext().setVertexLabelTransformer(new Transformer<Integer, String>() {
			@Override
			public String transform(Integer v) {
				return v.toString();
			}
		});*/
		viewer.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Integer>());
		viewer.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
		JFrame frame = new JFrame();
		frame.getContentPane().add(new GraphZoomScrollPane(viewer));
		frame.setSize(500,500);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
